package com.ijiuchuang.jc_localization.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by 王伟 on 2016/5/18.
 * Function :
 */
public abstract class BaseActivity extends AppCompatActivity {

    /**
     * Log Tag
     */
    protected static String TAG = null;

    /**
     * context
     */
    protected Context mContext = null;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);

        mContext = this;
        TAG = this.getClass().getSimpleName();

        /*initViews();
        initActions();*/
    }

    /*protected abstract void initViews();

    protected abstract void initActions();*/


    /**
     * startActivity
     *
     * @param clazz
     */
    protected void gotoActivity(Class<?> clazz) {
        Intent intent = new Intent(this, clazz);
        startActivity(intent);
    }

    /**
     * startActivity with bundle
     *
     * @param clazz
     * @param bundle
     */
    protected void gotoActivity(Class<?> clazz, Bundle bundle) {
        Intent intent = new Intent(this, clazz);
        if (null != bundle) {
            intent.putExtras(bundle);
        }
        startActivity(intent);
    }

    /**
     * startActivity then finish
     *
     * @param clazz
     */
    protected void gotoActivityWithFinish(Class<?> clazz) {
        Intent intent = new Intent(this, clazz);
        startActivity(intent);
        finish();
    }

    /**
     * startActivity with bundle then finish
     *
     * @param clazz
     * @param bundle
     */
    protected void gotoActivityWithFinish(Class<?> clazz, Bundle bundle) {
        Intent intent = new Intent(this, clazz);
        if (null != bundle) {
            intent.putExtras(bundle);
        }
        startActivity(intent);
        finish();
    }
}
